package cn.sciento.farm.devicemanager.common.constant;

/**
 * User: wumu
 * Date: 11/9/17
 * Time: 9:21 PM
 */
public enum ResultConstant {
    FAILED(0, "操作失败"),
    SUCCESS(1, "操作成功"),

    INVALID_LENGTH(10001, "不合理的长度"),

    INVALID_USERNAME(10103, "账号不存在"),
    INVALID_PASSWORD(10104, "密码错误"),
    INVALID_ACCOUNT(10105, "没有相关账号"),
    INVALUD_KAPTCHA(10106, "Invalid kaptcha"),
    ERROR_KAPTCHA(10106, "Error kaptcha"),
    LOCK_ACCOUNT(10107, "account locked"),
    ERROR_AUTHENTICATION(10108, "Authentication error"),
    FORBIDDEN_ACCOUNT(10109, "account forbidden"),
    INVALID_PARAMETER(10200, "参数不符合要求"),
    NULL_PARAMETER(10201, "参数不完整"),
    ILLEGAL_OPERATION(10202, "非法操作"),
    REPEAT_PARAMETER(10203, "重复的参数"),
    EMPTY_PHONE(10204, "手机号不能为空"),
    EMPTY_TENANT(10205, "租客不能为空"),
    NOT_DELETE(10206, "不能删除"),
    FIRST_DELETE_CHILDREN(10207, "请删除下级"),
    DUPLICATE_FORM(10208,"表单正在处理"),
    RATE_LIMIT(10209,"流量限制"),
    API_ABSOLETE(10210,"API接口过时"),
    ROLLBACK_EXCEPTION(10211,"操作失败"),
    EXIST_TENANT(10205, "租客已存在"),
    //    weixin
    WEIXIN_BOUND(10301, "微信账号已经被绑定了"),
    WEIXIN_NOT_BOUND(10302, "微信账号没有绑定账号"),


    //Sms
    SMS_SIXTY(10401, "一分钟内不能重复发送"),
    SMS_DAY_COUNT(10402, "今天短信发送已经使用完毕，请24小时后在发送"),

    //设备
    SWITCH_TIMEOUT(10901, "控制超时"),
    SWITCH_DOUBLE_WARN(10902, "不能对同一设备同时控制"),
    SWITCH_PART_CONTROL(10903, "设备实现部分控制"),
    SWITCH_LORAWAN_TIMEOUT(10904,"开关时间较长，请等待片刻"),
    SWITCH_HAS_CHILDREN(10905,"该设备下存在配置项，请先删除"),
    DEVICE_OFFLINE(10906,"设备不在线"),
    DEVICE_NOT_EXIST(10907,"设备不存在"),
    CONCENTRATOR_NOT_SUPPORT(10908,"该网关不支持"),
    ERROR_CON_DECODE(10909,"编号错误"),
    NOT_SET_INVERTER(10910,"没有设置变频器"),
    SET_PRESSURE_FAILURE(10911,"设定压力失败"),
    SET_MULTI_SCENE(10912,"同一设备设置多个灌溉场景"),
    SWITCH_FORWARE_REVERSE(10913,"正转与反转不能快速切换"),
    FERTILIZER_HAD(10914,"该水肥机已经分配，请联系管理员"),
    SCREEN_EXCEED_DEVICE(10915,"超出屏幕关联的网关数目"),
    SCREEN_MULTI_DEVICE(10916,"一个基地只能有一台注入式水肥机"),
    //tenant
    TENANT_HAVE_USER(11000, "租客还有用户"),
    TENANT_LIMIT(11001, "您已经达到了上限，请联系管理员"),

    //camera
    CAMERA_REPEAT(12000, "摄像头已经添加，请联系管理员"),
    CAMERA_NOT_EXIST(12001, "摄像头不存在，请选择其他摄像头"),
    // area
    CON_NOT_EMPTY(12100,"该基地存在网关,请先删除"),

    // 错误
    INTERNAL_ERROR(12150,"内部错误"),

    //用户
    ROLE_HAVE_USER(23000, "有用户绑定角色，不能删除"),
    AUTHORITY_GROUP_HAS_CHILDREN(23001, "该组存在权限"),
    DOUBLE_ACCOUNT(23002, "请重新生成账号");
    public int code;

    public String message;

    ResultConstant(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static ResultConstant match(int code) {
        for (ResultConstant resultConstant : ResultConstant.values()) {
            if (resultConstant.getCode() == code) {
                return resultConstant;
            }
        }
        return SUCCESS;
    }

}
